package ac.neec.mio.record.search;


/**
 * Created by G011C1093 on 14/01/27.
 */
public class InputDataChecker {

	private static int sYear;
	private static int sMonth;
	private static int sDay;
	private static int eYear;
	private static int eMonth;
	private static int eDay;
	private static StringBuilder dialogAlert;
	private static final String AGE_ALERT = "年齢が未入力です";
	private static final String HEIGHT_ALERT = "身長が未入力です";
	private static final String WEIGHT_ALERT = "体重が未入力です";
	private static final String RESTIGN_HEART_ALERT = "安静時心拍数が未入力です";
	private static final String NEW_LINE = "\n";

	public static int getsYear() {
		return sYear;
	}

	public static int getsMonth() {
		return sMonth;
	}

	public static int getsDay() {
		return sDay;
	}

	public static int geteYear() {
		return eYear;
	}

	public static int geteMonth() {
		return eMonth;
	}

	public static int geteDay() {
		return eDay;
	}

	protected InputDataChecker() {
	}

	protected static void setSrartDate(int sYear, int sMonth, int sDay) {
		InputDataChecker.sYear = sYear;
		InputDataChecker.sMonth = sMonth;
		InputDataChecker.sDay = sDay;
	}

	protected static void setEndDate(int eYear, int eMonth, int eDay) {
		InputDataChecker.eYear = eYear;
		InputDataChecker.eMonth = eMonth;
		InputDataChecker.eDay = eDay;
	}

	protected static boolean checkStartDate(int sYear, int sMonth, int sDay) {
		if (sYear > eYear)
			return false;
		else if (sMonth > eMonth)
			return false;
		else if (sMonth == eMonth && sDay > eDay)
			return false;

		return true;
	}

	public static boolean insertDataChecker(int age, int height,
			int weight, int restingHeart) {
		if (age == 0 || height == 0 || weight == 0 || restingHeart == 0) {
			dialogAlert = new StringBuilder();
			dialogAlert.append(NEW_LINE);
			if (age == 0)
				dialogAlert.append(AGE_ALERT+NEW_LINE);
			if (height == 0) {
				dialogAlert.append(HEIGHT_ALERT+NEW_LINE);
			}
			if (weight == 0) {
				dialogAlert.append(WEIGHT_ALERT+NEW_LINE);
			}
			if (restingHeart == 0) {
				dialogAlert.append(RESTIGN_HEART_ALERT+NEW_LINE);
			}
			return false;
		}
		return true;
	}

	public static String getDialogAlert() {
		return String.valueOf(dialogAlert);
	}

	protected static boolean checkEndDate(int eYear, int eMonth, int eDay) {
		if (sYear > eYear)
			return false;
		else if (sMonth > eMonth)
			return false;
		else if (sMonth == eMonth && sDay > eDay)
			return false;

		return true;
	}
}
